package com.hutao.sso.service.impl.user;


import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hutao.sso.mapper.TBnzlysMapper;
import com.hutao.sso.mapper.TCzyMapper;
import com.hutao.sso.pojo.TBnzlys;
import com.hutao.sso.pojo.TCzy;
import com.hutao.sso.pojo.authority.Authority;
import com.hutao.sso.service.UserService;

@Service
public class UserServiceImpl implements UserService {

	@Autowired
	private TBnzlysMapper tBnzlysMapper;
	
	@Autowired
	private TCzyMapper tCzyMapper;
	
	/**
	 * 医生
	 */
	@Override
	public TBnzlys findDoctorByCardidAndOrgCode(Map<String, Object> params) {
		return tBnzlysMapper.findDoctorByCardidAndOrgCode(params);
	}

	/**
	 * 操作员登录
	 */
	@Override
	public TCzy findOperationByCardidAndOrgCode(Map<String, Object> params) {
		return tCzyMapper.findOperationByCardidAndOrgCode(params);
	}

	/**
	 * 旧系统
	 * 获取某个机构下的某个操作员的所有权限
	 */
	@Override
	public List<Authority> findOperationAuthorityList(Map<String, Object> params) {
		TCzy tczy = tCzyMapper.findOperationByCardidAndPasswordAndOrgCode(params);
		String authoritys = tczy.getJinruqx();
		List<Authority> authorityList = new ArrayList<>();;
		
		if(StringUtils.isNotBlank(authoritys)) {
			for(String permissionname : authoritys.split(",")) {
				Authority authority = new Authority();
				authority.setPermissionname(permissionname);
				authorityList.add(authority);
			}
		}
		return authorityList;
	}
	
	
	
	
	
}


